Text classification and model training method and system based on collaborative learning of large and small models

By introducing a method of collaborative learning of large models into text classification small models, the problem of insufficient training data of small models is solved and the model performance is improved.

CN119293252BActive Publication Date: 2025-02-28ASIAINFO TECH CHINA INC
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411815341.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-02-28
Estimated Expiration
2044-12-11

AI Technical Summary

Technical Problem

In practical applications, the training data of text classification small models is difficult to obtain or the quality is low, resulting in insufficient model performance.

Method used

Using a method based on collaborative learning of size and models, training data is generated by calling large models, and using these data to optimize training of small models until the model effect meets the setting requirements.

Benefits of technology

Generate high-quality training data through large models, ensuring that the small model has sufficient training data for optimization training, solving the problem of insufficient training data, and gradually improving the performance of text classification models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The present application discloses a text classification and model training method and system based on collaborative learning of large and small models, and relates to the field of natural language processing technology. The present application obtains sample data of the current round, and uses a large model to generate training data based on the sample data. The text classification model is trained and optimized using the training data. If the effect of the text classification model does not meet the preset standard, the quality of each training data will be evaluated, and high-quality training data will be selected as the sample data for the next round. Repeat this process until the model meets the set requirements and the final text classification model is obtained. By continuously generating and evaluating training data, a closed-loop optimization process is formed, in which the large model and the small text classification model learn collaboratively and promote each other during the optimization process until the effect of the optimized text classification model meets the set requirements. This not only solves the problem of insufficient training data, but also helps to improve the performance of the text classification model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and more specifically, to a text classification and model training method and system based on collaborative learning of large and small models. Background Art

[0002] In the field of natural language processing (NLP), text classification is a basic and important task that aims to assign text data to predefined categories. With the rapid development of deep learning technology, text classification models based on deep learning have gradually become a hot topic in research and application. Classic small text classification models, such as TextCNN, TextRNN, FastText, TextRCNN, and Transformer, have attracted widespread attention due to their performance on different data sets and tasks. Choosing a suitable model usually depends on the requirements of the specific task, the characteristics of the data set, and the available computing resources. However, in practical applications, sometimes the training data for the small model is difficult to obtain, or the quality of the training data is not high, which in turn affects the performance of the model.

[0003] Therefore, providing an effective solution to solve the problem of insufficient training effect of small text classification models has become a research topic for technical personnel in this field. Summary of the invention

[0004] In view of the above problems, this application is proposed to provide a text classification and model training method and system based on collaborative learning of large and small models to improve the training effect of the small text classification model and thus improve the text classification effect. The specific scheme is as follows:

[0005] In a first aspect, a model training method based on collaborative learning of large and small models is provided, comprising:

[0006] Obtaining sample data of the current round, wherein the sample data can be used as training data for a text classification model, wherein the text classification model is a model with a smaller parameter scale than a large model;

[0007] Calling the configured big model to instruct the big model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and obtain the training data generated by the big model in the current round;

[0008] Optimizing and training the text classification model using the training data generated in the current round to obtain the text classification model after the current round of training, and evaluating whether the effect of the text classification model after the current round of training meets the set requirements;

[0009] If not, for each training data generated in the current round, at least based on the contribution of each training data to the optimization training process of the text classification model, obtain the quality score of each training data, and select the training data that meets the set high quality requirements as the sample data for the next round, return to execute the process of calling the big model to generate the next round of training data, and use the next round of training data to optimize the training of the text classification model, until the effect of the text classification model after the current round of training meets the set requirements, and the final text classification model is obtained.

[0010] In one possible design, in another implementation of the first aspect of the embodiment of the present application, the process of obtaining the quality score of each training data based at least on the contribution of each training data to the optimization training process of the text classification model includes:

[0011] Determine the contribution of each piece of training data to the optimization training process of the text classification model;

[0012] Determine the maximum similarity between each training data and the historical training data obtained before the current round;

[0013] The quality score of each training data is obtained by referring to the contribution and the maximum similarity of each training data, wherein the contribution is positively correlated with the quality score, and the maximum similarity is negatively correlated with the quality score.

[0014] In a possible design, in another implementation of the first aspect of the embodiment of the present application, calling a configured large model to instruct the large model to refer to the sample data of the current round to generate training data that can be used to train a text classification model includes:

[0015] Obtain a prompt instruction prompt format template, wherein the prompt format template includes a task instruction and a sample data slot, wherein the task instruction is used to instruct the large model to generate training data for training a text classification model according to the sample data in the sample data slot;

[0016] Fill the sample data of the current round into the sample data slot to obtain a first prompt instruction prompt, input the first prompt instruction prompt into the large model, and obtain the training data generated by the current round of the large model.

[0017] In a possible design, in another implementation of the first aspect of the embodiment of the present application, the process of evaluating whether the effect of the text classification model after the current round of training meets the set requirements includes:

[0018] Use the configured test set to evaluate the text classification model after the current round of training to obtain the evaluation indicators of the current round;

[0019] Determine whether the effect of the text classification model after the current round of training meets the set requirements based on whether the evaluation indicators of the current round reach the set indicator threshold;

[0020] or,

[0021] Compare the evaluation indicators of the current round with those of the previous round, and determine whether the effect of the text classification model after the current round of training meets the set requirements based on the comparison results.

[0022] In a possible design, in another implementation of the first aspect of the embodiments of the present application, the process of obtaining sample data of the current round includes:

[0023] If the current round is the first round, several training data are randomly selected from the configured training set as sample data for the current round.

[0024] In a possible design, in another implementation manner of the first aspect of the embodiments of the present application, before obtaining the sample data of the current round, the method further includes:

[0025] Performing initial training on the initial text classification model using the configured training set to obtain the text classification model after initial training;

[0026] The configured test set is applied to perform an evaluation test on the text classification model after the initial training, and when it is determined that the effect of the text classification model after the initial training does not meet the set requirements, the step of obtaining the sample data of the current round is performed.

[0027] Secondly, a text classification method based on collaborative learning of large and small models is provided, including:

[0028] Get the text to be classified;

[0029] Sending the text to be classified into a text classification model to obtain a classification result output by the model;

[0030] The text classification model is a model trained by the text classification model training method according to any one of the first aspects mentioned above.

[0031] In a third aspect, a model training device based on collaborative learning of large and small models is provided, comprising:

[0032] A data acquisition unit, used to acquire sample data of the current round, wherein the sample data can be used as training data for a text classification model, wherein the text classification model is a model with a smaller parameter scale than a large model;

[0033] A training data generating unit, used to call the configured large model to instruct the large model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and obtain the training data generated by the large model in the current round;

[0034] A model optimization training and evaluation unit, used to optimize the text classification model using the training data generated in the current round, obtain the text classification model after the current round of training, and evaluate whether the effect of the text classification model after the current round of training meets the set requirements;

[0035] The data scoring unit is used to obtain the quality score of each training data generated in the current round, at least based on the contribution of each training data to the optimization training process of the text classification model, when the effect of the text classification model after the current round of training does not meet the set requirements, and select the training data that meets the set high quality requirements as the sample data for the next round, return to the execution training data generation unit, until the effect of the text classification model after the current round of training meets the set requirements, and obtain the final text classification model.

[0036] In a fourth aspect, a text classification device based on collaborative learning of large and small models is provided, comprising:

[0037] A text acquisition unit, used for acquiring text to be classified;

[0038] An output unit is used to input the text to be classified into a text classification model to obtain a classification result output by the model; wherein the text classification model is a model trained by the model training method based on collaborative learning of large and small models described in any one of the first aspects mentioned above.

[0039] In a fifth aspect, an electronic device is provided, comprising: a memory and a processor;

[0040] The memory is used to store programs;

[0041] The processor is used to execute the program to implement the various steps of the model training method based on collaborative learning of large and small models described in any one of the first aspects of the present application, or to implement the text classification method based on collaborative learning of large and small models described in any one of the second aspects of the present application.

[0042] In a sixth aspect, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the various steps of the model training method based on collaborative learning of large and small models described in any one of the first aspects of the present application are implemented, or the text classification method based on collaborative learning of large and small models described in any one of the second aspects of the present application is implemented.

[0043] In the seventh aspect, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the computer program implements the various steps of the model training method based on collaborative learning of large and small models described in any one of the first aspects of the present application, or implements the text classification method based on collaborative learning of large and small models described in any one of the second aspects of the present application.

[0044] By means of the above technical scheme, the model training method based on collaborative learning of large and small models proposed in this application first obtains the sample data of the current round, then calls the configured large model, and instructs the large model to refer to the sample data of the current round to generate training data that can be used to train the text classification model. After obtaining the training data, the text classification model is optimized and trained using the training data generated in the current round to obtain the text classification model after the current round of training. The large model uses the sample data to continuously generate training data, so that the small model can have enough training data for optimization training, solving the problem of insufficient training data. Then, it is evaluated whether the effect of the text classification model after the current round of training meets the set requirements. If not, the quality score of each training data is calculated, and the quality score is obtained based on at least the contribution of each training data in the optimization training process of the text classification model. According to the quality score, the training data that meets the set high quality requirements is selected as the sample data of the next round, and the call to the large model is returned to generate the next round of training data until the effect of the text classification model after the current round of training meets the set requirements, and the final text classification model is obtained. By evaluating the classification effect of the text classification model after the current round of training, the deficiencies of the training data generated by the large model can be discovered in a timely manner, so that targeted improvements can be made. By continuously generating and evaluating training data, a closed-loop optimization process is formed. The large model and the text classification model learn collaboratively and promote each other in the optimization process until the effect of the optimized text classification model meets the set requirements. This not only solves the problem of insufficient training data, but also helps to gradually improve the performance of the text classification model. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0046] Figure 1 A flow chart of a model training method based on collaborative learning of large and small models provided in an embodiment of the present application;

[0047] Figure 2A schematic diagram of another flow chart of a model training method based on collaborative learning of large and small models provided in an embodiment of the present application;

[0048] Figure 3 A schematic diagram of the structure of a text classification device based on collaborative learning of large and small models provided in an embodiment of the present application;

[0049] Figure 4 A schematic diagram of the structure of a model training device based on collaborative learning of large and small models provided in an embodiment of the present application;

[0050] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0051] Before introducing this application, the English terms involved in this article are explained first:

[0052] prompt: Instructions. When interacting with AI (such as an artificial intelligence model), you need to send instructions to AI. It can be a text description, such as "Please recommend me a pop song" when you interact with AI, or it can be a parameter description in a certain format. For example, if you want AI to draw in a certain format, you need to describe the relevant drawing parameters.

[0053] Large models: In the field of artificial intelligence, large models usually refer to large-scale pre-trained models. Such models are called "large" because they can be pre-trained on a large amount of data and can be transferred to a variety of downstream tasks. Their full English name is Large Pre-Trained Models or Large-Scale Pre-Training Models. Large models are characterized by their large scale and contain billions or even more parameters, which help them learn complex patterns in the data. The emerging capabilities of large models include but are not limited to: contextual learning, instruction following, code generation, step-by-step reasoning capabilities, etc. Large models can include large language models (LLM), as well as multimodal large models. Large language models are mainly used to process text modal data. Multimodal large models further integrate multimodal capabilities on the basis of large language models and can process information in multiple modalities, such as images, text, audio, etc.

[0054] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] In the field of natural language processing (NLP), text classification is a basic and critical task, whose goal is to accurately assign text data to predefined categories. With the rapid development of deep learning technology, deep learning-based text classification models, such as TextCNN, TextRNN, FastText, TextRCNN, and Transformer, have become a hot topic in research and application. These small models have attracted widespread attention due to their performance on different datasets and tasks. Choosing a suitable model usually depends on task requirements, dataset characteristics, and the availability of computing resources.

[0056] However, in practical applications, sometimes it is difficult to obtain training data for small models, or the quality of the training data is not high, which in turn affects the performance of the model.

[0057] In order to overcome this problem, the inventors began to explore the possibility of using large models to generate training data. Large models, with their huge parameter scale and deep neural network architecture, show strong expressiveness and accuracy. They can learn the deep laws of language from a large amount of unlabeled text data through self-supervised or semi-supervised learning strategies, and generate training data required for various tasks. In an initial design, the process of generating training data for the large model is separated from the process of training the small model using training data. That is, the training data is generated by the large model and passed to the small model for training. However, the inventors found that the above scheme still has shortcomings in the collaboration between the large model and the small model. There is no two-way interaction between the two, and mutual enhancement of performance cannot be achieved.

[0058] Based on the above problems, the inventors further provided a solution for the cooperation between the large model and the small model, which can effectively combine the generation capability of the large model and the classification expertise of the small model, and improve the classification effect of the trained small model through two-way interaction and collaborative learning.

[0059] The following embodiments of the present application respectively provide a model training method based on collaborative learning of large and small models (i.e., a training method for a small text classification model) and a text classification method. Among them, the provided model training method and text classification method can be applied to electronic devices. Exemplarily, the electronic device can be, for example, a server, a robot, a smart phone (mobile phone), a personal computer (PC), a laptop computer, a wireless electronic device in industrial control, etc.

[0060] The method provided in the present application can be divided into a training phase and an inference phase. The training phase is the phase of training the text classification model, and the inference phase is the phase of using the trained text classification model to classify the acquired text to be classified. Among them, the training phase and the inference phase can be deployed in the same device or in different devices. For example, the training phase can be deployed in the cloud or in a server, and the inference phase can be deployed in an intelligent terminal, such as a mobile phone, a tablet, a smart car, a robot, or a wearable device.

[0061] For ease of understanding, this application introduces the processes of the training phase and the reasoning phase respectively.

[0062] 1. Training Phase

[0063] See also Figure 1 The present application provides a flow chart of a training method for a model based on collaborative learning of large and small models, as described below, which specifically includes the following steps:

[0064] Step S100: Obtain sample data of the current round.

[0065] The sample data can be used as training data for a text classification model, which is a model with a smaller parameter scale relative to a large model. It can be a small NLP model based on neural network training such as BERT, FastText, TextCNN, TextRNN, TextRCNN and Transformer, or a large model with a smaller parameter scale, such as Phi-2 (2.7B).

[0066] Specifically, the sample data of the current round is obtained. The purpose of this step is to use the large model to generate training data based on the sample data of the current round, so that the text classification model can use the training data for training optimization. That is, the quality of the sample data will affect the performance of the text classification model. Specifically, the sample data includes two parts: training text and classification labels corresponding to the training text.

[0067] During the training process of the text classification model, the sample data for the current round can be obtained by screening the training data generated by the large model in the previous round, and obtaining training data that meets high-quality standards. This method allows the large model to refer to high-quality sample data in each round of training, thereby improving the quality of the generated training data. If the current round is the first round of the entire training process, the sample data can be obtained by randomly selecting a certain number of samples from the pre-configured training set. This random selection method helps to introduce data diversity and lay a solid foundation for subsequent training.

[0068] Step S110, calling the configured big model to instruct the big model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and obtain the training data generated by the big model in the current round.

[0069] Specifically, in the embodiment of the present application, a pre-configured large model will be used to assist in the training of the text classification model. This large model will be called to refer to the sample data obtained in the current round, so that it can generate training data suitable for training the text classification model. The large model generates new training data based on these sample data, and these training data can be used to train a text classification model with a smaller parameter scale.

[0070] In one possible implementation, large models can generate training data in batches. This approach can avoid two common problems: one is to prevent the number of context tokens in the large model from exceeding the limit during inference, and the other is to reduce the situation where the generated training data is too similar. By generating data in batches, the diversity of training data can be improved.

[0071] Optionally, when the large model generates training data, a small number of sample prompt techniques may be used. The sample data of the current round obtained in this step is used as the sample in the prompt instruction prompt input when the large model generates training data in this round.

[0072] In one possible implementation, the large model does not obtain sample data, and a zero-sample prompting technique can be used to generate training data.

[0073] Step S120: Optimize and train the text classification model using the training data generated in the current round to obtain a text classification model after the current round of training.

[0074] Specifically, the training data generated in the current round is used to optimize the text classification model and obtain the text classification model after the current round of training.

[0075] In one possible implementation, in order to ensure the stability and reliability of the text classification model in subsequent evaluations, the model parameter settings can be kept consistent with the training parameters of the previous round as much as possible, which can ensure the continuity and consistency of the model in different training stages and avoid affecting the evaluation of the text classification model performance due to sudden changes in parameter settings.

[0076] Step S130, evaluating whether the effect of the text classification model after the current round of training meets the set requirements. If the set requirements are met, step S160 is executed; if not, step S140 is executed.

[0077] Specifically, the configured test set can be used to evaluate the text classification model after the current round of training to obtain the evaluation effect of the current round. If the text classification model of the current round meets the set requirements, step S160 is executed, and if it does not meet the set requirements, step S140 is executed.

[0078] Step S140: For each piece of training data generated in the current round, a quality score of each piece of training data is obtained based at least on the contribution of each piece of training data to the optimization training process of the text classification model.

[0079] Specifically, in the training data generated in the current round, the quality score of each data is a key indicator. The size of the quality score is related to the impact of the training data on the training of the text classification model. The data with higher quality scores can promote the training of the text classification model, and the data with lower quality scores has less impact on the training of the text classification model.

[0080] In a possible implementation, the present application can calculate the quality score of each training data from the perspective of contribution. The contribution of training data and the quality score are positively correlated, that is, the higher the contribution of the training data, the higher the quality score; the lower the contribution of the training data, the lower the quality score.

[0081] In the text classification training model, you can combine different algorithms to evaluate the contribution of each training data to the model training stage. The following are examples of three methods. You can also choose other methods to calculate the contribution of training data to model training.

[0082] ① Loss function: Calculate the contribution of each training data to the change in the loss function value during the text classification model training process. If the addition of a certain data significantly reduces the value of the loss function, then it can be considered that this data has a greater contribution to the model training.

[0083] ② Gradient analysis method: Each time the parameters of the text classification model are updated, the gradient value corresponding to each training data is recorded. The size of the gradient can reflect the contribution of the training data to the update of the parameters of the text classification model.

[0084] ③ Parameter analysis method: Evaluate the contribution of each training data by observing its proportion in the update of text classification model parameters. If a piece of data causes a significant change in the model parameters, it is considered to have a high contribution.

[0085] Step S150: Select training data that meets the set high quality requirements as sample data for the next round.

[0086] Specifically, through the above-mentioned quality scoring of each training data, the quality of each training data in the current round of large model generated training data is obtained. In order to better guide the large model to generate higher quality training data in the next round, in this step, training data whose quality meets the set requirements can be selected from the current round of training data as sample data for the next round for use by the large model.

[0087] On this basis, we can return to the above step S110 to execute the process of calling the large model to generate the next round of training data, and using the next round of training data to optimize the text classification model until the effect of the text classification model after the current round of training meets the set requirements.

[0088] Step S160: Obtain the final text classification model.

[0089] Specifically, through the above-mentioned iterative process, the large model continuously generates high-quality training data for optimization training of the text classification model, until the effect of the text classification model meets the set requirements after a certain round of iterative training, and the final text classification model can be obtained.

[0090] The model training method based on collaborative learning of large and small models proposed in the embodiment of the present application first obtains the sample data of the current round, then calls the configured large model, and instructs the large model to refer to the sample data of the current round to generate training data that can be used to train the text classification model. After obtaining the training data, the training data generated in the current round is used to optimize the text classification model to obtain the text classification model after the current round of training. The large model uses the sample data to continuously generate training data, so that the small model can have enough training data for optimization training, which solves the problem of insufficient training data. Then evaluate whether the effect of the text classification model after the current round of training meets the set requirements. If not, calculate the quality score of each training data, at least based on the contribution of each training data in the optimization training process of the text classification model to obtain the quality score, select the training data that meets the set high quality requirements as the sample data of the next round according to the quality score, and return to execute the call to the large model to generate the next round of training data, until the effect of the text classification model after the current round of training meets the set requirements, and obtain the final text classification model. This method ensures that the model can learn from the most valuable data in each round of training, thereby gradually improving its classification accuracy and generalization ability. By evaluating the classification effect of the text classification model after the current round of training, the deficiencies of the training data generated by the large model can be discovered in a timely manner, so that targeted improvements can be made. By continuously generating and evaluating training data, a closed-loop optimization process is formed. The large model and the text classification model promote each other in the optimization process until the effect of the optimized text classification model meets the set requirements. This not only solves the problem of insufficient training data, but also helps to gradually improve the performance of the text classification model.

[0091] Furthermore, in some embodiments of the present application, before obtaining the sample data of the current round, initial training and evaluation of the text classification model may also be included, referring to Figure 2 , the specific process is as follows:

[0092] Step S200: Perform initial training on the initial text classification model using the configured training set to obtain the text classification model after initial training.

[0093] Specifically, the initial text classification model can be initially trained using a pre-configured training set to obtain the text classification model after initial training, which lays a solid foundation for subsequent iterative optimization and adjustment. Although the performance of the model may not have reached the optimal level at this time, it already has the basic ability to classify text and is ready for further learning.

[0094] Step S210: Use the configured test set to evaluate the text classification model after initial training to evaluate whether it meets the set requirements. If the set requirements are met, execute step S280; if not, execute step S220.

[0095] Specifically, the configured test set can be used to evaluate the text classification model after the current round of training to obtain the evaluation index of the current round, and the performance of the model can be measured through a series of evaluation indicators, such as accuracy, precision, recall rate and F1 score. If the set requirements are met, step S280 is executed, and if not, step S220 is executed.

[0096] Step S220: Obtain sample data of the current round.

[0097] Step S230, calling the configured big model to instruct the big model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and obtain the training data generated by the big model in the current round.

[0098] Step S240: Optimize and train the text classification model using the training data generated in the current round to obtain a text classification model after the current round of training.

[0099] Step S250, evaluating whether the effect of the text classification model after the current round of training meets the set requirements. If the set requirements are met, step S280 is executed; if not, step S260 is executed.

[0100] Step S260: For each piece of training data generated in the current round, a quality score of each piece of training data is obtained based at least on the contribution of each piece of training data to the optimization training process of the text classification model.

[0101] Step S270: Select training data that meets the set high quality requirements as sample data for the next round.

[0102] Step S280: Obtain the final text classification model.

[0103] Specifically, the above steps S220-S280 correspond one-to-one to steps S100-S160 in the aforementioned embodiment, and please refer to the above introduction for details, which will not be repeated here.

[0104] In the present embodiment, the initial text classification model is systematically trained using the training set, which lays a solid foundation for the model. Although the model may not have reached the optimal performance at this time, it has basic text classification capabilities and is ready for further learning. Next, the model after initial training is evaluated by applying the configured test set. If the evaluation result of the model meets the preset requirements, step S280 will be executed to obtain the final text classification model. If the evaluation result is not up to standard, further optimization is required, which indicates that the model still has room for improvement, and its performance needs to be improved through iterative training and parameter adjustment, ensuring the effectiveness and reliability of the model in practical applications. Through this process, the accuracy of the model when processing new data is ensured, thereby providing high-quality text classification services in practical applications.

[0105] In some embodiments of the present application, for the process of step S110 in the aforementioned embodiment, a prompt format template may be used. The following describes the process of generating training data using the prompt format template:

[0106] Optionally, a prompt format template is obtained, the prompt format template includes a task instruction and a sample data slot, wherein the sample data slot is used to fill the sample data, and the task instruction is used to instruct the large model to generate training data for training the text classification model according to the sample data in the sample data slot.

[0107] An example prompt format template may include:

[0108] As a natural language processing expert, please refer to the given sample data and generate data for training the text classification model.

[0109] The sample data is as follows: {sample data slot}.

[0110] Then fill the sample data of the current round into the sample data slot to obtain the edited first prompt instruction prompt, and input the first prompt instruction prompt into the large model. The large model can understand the first prompt instruction prompt and process it according to the task requirements in the prompt to obtain the training data generated by the current round of the large model.

[0111] In this embodiment, by using a prompt format template to generate training data, iteration and optimization can be performed more easily, and a large model can be quickly guided to generate higher quality training data.

[0112] In some embodiments of the present application, for the process of evaluating whether the effect of the text classification model after the current round of training meets the set requirements in step S130 in the aforementioned embodiment, a series of evaluation indicators can be set to determine whether the text classification model of the current round meets the set requirements. For example, the recall rate, precision rate, etc. of the classification are used as evaluation indicators to measure the performance of the text classification model.

[0113] Optionally, you can use a variety of methods to determine whether the evaluation indicators of the text classification model after the current round of training meet the set requirements. The following are two methods, and you can also choose other methods to make judgments:

[0114] ① Determine whether the effect of the text classification model after the current round of training meets the set requirements based on whether the evaluation indicators of the current round reach the set indicator threshold. That is, before the training starts, one or more performance indicator thresholds can be set according to business needs and historical data. After each round of training, the evaluation indicators of the text classification model can be compared with these preset thresholds, which helps to evaluate whether the text classification model meets the set requirements.

[0115] ② Compare the evaluation indicators of the current round with those of the previous round, and determine whether the effect of the text classification model after the current round of training meets the set requirements based on the comparison results. That is, compare the evaluation indicators of the current round with those of the previous round. This method can understand the changing trend of model performance and determine whether the model is continuously improving. If the evaluation indicators of the current round show obvious progress, or at least remain the same as the previous round, this indicates that the text classification model is moving in the right direction. If the evaluation indicators of the previous round have declined, this may be a signal that the text classification model needs further optimization in some aspects. Various strategies such as model structure adjustment and sample data selection can be adopted to improve the performance of the model.

[0116] The advantages of these two evaluation methods in this embodiment are that they set clear evaluation index thresholds for model training, thereby quickly feeding back the performance of the text classification model and supporting continuous optimization. At the same time, the trend analysis of the second method helps monitor the progress of the text classification model, adjust the strategy in time, ensure the effective use of resources, and improve development efficiency.

[0117] In some embodiments of the present application, a comprehensive consideration method can be adopted to calculate the quality score of each training data. That is, when calculating the quality score of each training data, it is possible to consider both the contribution of each training data to the model and its maximum similarity with the historical training data obtained before the current round. Specifically, the quality score of each training data not only reflects its contribution to the improvement of model performance, but also considers the maximum similarity between the data and the previous historical training data. The contribution of the training data is directly proportional to the quality score, and the similarity of the training data is negatively correlated with the quality score.

[0118] Optionally, a formula can be used to reflect the contribution and similarity of each training to obtain a quality score. The quality score formula is as follows:

[0119]

[0120] Among them, I is the contribution of training data to model training, C is the similarity between the training data and historical training data, It represents the similarity between data i and data j, and S represents the generated data set.

[0121] As an optional method, there are also multiple methods for calculating similarity. The following is an example of a method for calculating similarity:

[0122] ① Cosine similarity: It is used to compare the directionality of text data. It converts the text into a vector and then calculates the cosine value of the angle between the two vectors to determine the similarity. It can capture the semantic information of the text data well.

[0123] ②Euclidean distance: It can be used to measure the similarity of numerical features. It works by calculating the straight-line distance between two points. In text data, word embedding vectors can be used as features, and then the Euclidean distance between new data points and historical data points can be calculated. The smaller the distance, the higher the similarity.

[0124] In this embodiment, by comprehensively considering contribution and similarity to evaluate the quality of training data, it can be ensured that the generated training data not only has a positive impact on model performance, but also has sufficient diversity. The advantage of this method is that it can balance the novelty of the data, avoid overfitting, and promote the improvement of the generalization ability of the model. In this way, the training data can be used more effectively to improve the efficiency and quality of text classification model training.

[0125] 2. Reasoning Stage

[0126] After completing the training of the text classification model, the text classification model can be deployed to an online environment for reasoning applications.

[0127] This embodiment provides a text classification method based on collaborative learning of large and small models, which may include the following steps:

[0128] First, obtain the text to be classified.

[0129] The text can be reports covering different fields such as politics, economy, sports, entertainment, etc., or text records of customer inquiries, complaints and support requests, or academic articles in the fields of science, technology, medicine, etc.

[0130] Furthermore, the text to be classified is sent to the text classification model to obtain the classification result output by the model, that is, the category to which the text belongs.

[0131] Since the text classification model obtained by the aforementioned training method has better performance, the method of this application can improve the text classification effect.

[0132] The following is a description of a text classification device based on collaborative learning of large and small models provided in an embodiment of the present application. The text classification device described below and the text classification method based on collaborative learning of large and small models described above can refer to each other.

[0133] See also Figure 3 , Figure 3 A schematic diagram of the structure of a text classification device based on collaborative learning of large and small models disclosed in an embodiment of the present application.

[0134] like Figure 3 As shown, the device may include:

[0135] A text acquisition unit 11, used to acquire the text to be classified;

[0136] The output unit 12 is used to input the text to be classified into a text classification model to obtain a classification result output by the model, wherein the text classification model is a model trained by the text classification model training method in the above-mentioned embodiment.

[0137] In some embodiments of the present application, a model training device based on collaborative learning of large and small models is further provided. The model training device based on collaborative learning of large and small models described below and the model training method based on collaborative learning of large and small models described above can refer to each other.

[0138] See also Figure 4 , Figure 4 A schematic diagram of the structure of a model training device based on collaborative learning of large and small models disclosed in an embodiment of the present application.

[0139] like Figure 4 As shown, the device may include:

[0140] A data acquisition unit 21 is used to acquire sample data of the current round, wherein the sample data can be used as training data for a text classification model, and the text classification model is a model with a smaller parameter scale than a large model;

[0141] A training data generating unit 22 is used to call the configured large model to instruct the large model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and obtain the training data generated by the large model in the current round;

[0142] A model optimization training and evaluation unit 23 is used to optimize the text classification model using the training data generated in the current round, obtain the text classification model after the current round of training, and evaluate whether the effect of the text classification model after the current round of training meets the set requirements;

[0143] The data scoring unit 24 is used to obtain the quality score of each training data generated in the current round, at least based on the contribution of each training data to the optimization training process of the text classification model when the effect of the text classification model after the current round of training does not meet the set requirements, and select the training data that meets the set high quality requirements as the sample data for the next round, and return to execute the training data generation unit 22 until the effect of the text classification model after the current round of training meets the set requirements to obtain the final text classification model.

[0144] Optionally, a model training device based on collaborative learning of large and small models in an embodiment of the present application further includes:

[0145] An initial training unit, which uses a configured training set to perform initial training on an initial text classification model to obtain a text classification model after initial training;

[0146] The evaluation unit applies the configured test set to perform an evaluation test on the text classification model after the initial training, and executes the data acquisition unit 21 when it is determined that the effect of the text classification model after the initial training does not meet the set requirements.

[0147] In a possible implementation, the process of the data acquisition unit 21 acquiring the sample data of the current round includes: if the current round is the first round, randomly selecting a number of training data in the configured training set as the sample data of the current round.

[0148] In a possible implementation, the training data generating unit 22 calls the configured large model to instruct the large model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and the process of obtaining the training data generated by the large model in the current round includes:

[0149] Obtain a prompt instruction prompt format template, wherein the prompt format template includes a task instruction and a sample data slot, wherein the task instruction is used to instruct the large model to generate training data for training a text classification model according to the sample data in the sample data slot;

[0150] Fill the sample data of the current round into the sample data slot to obtain a first prompt instruction prompt, input the first prompt instruction prompt into the large model, and obtain the training data generated by the current round of the large model.

[0151] In a possible implementation, the process in which the model optimization training and evaluation unit 23 evaluates whether the effect of the text classification model after the current round of training meets the set requirements includes:

[0152] Use the configured test set to evaluate the text classification model after the current round of training to obtain the evaluation indicators of the current round;

[0153] Determine whether the effect of the text classification model after the current round of training meets the set requirements based on whether the evaluation indicators of the current round reach the set indicator threshold;

[0154] or,

[0155] Compare the evaluation indicators of the current round with those of the previous round, and determine whether the effect of the text classification model after the current round of training meets the set requirements based on the comparison results.

[0156] The present application also provides an electronic device in an embodiment. Figure 5 As shown, it shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiment of the present application. The electronic device in the embodiment of the present application may include but is not limited to fixed terminals such as mobile phones, tablet computers, teaching large screens, wearable devices, etc. Figure 5 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0157] like Figure 5As shown, the electronic device may include a processing device (such as a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 to a random access memory (RAM) 603, so as to implement the text classification method based on the collaborative learning of large and small models in the aforementioned embodiment of the present application, or to implement the model training method based on the collaborative learning of large and small models in the aforementioned embodiment of the present application. When the electronic device is powered on, various programs and data required for the operation of the electronic device are also stored in RAM 603. The processing device 601, ROM 602 and RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0158] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a memory card, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 An electronic device having various devices is shown, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0159] Also provided in an embodiment of the present application is a computer program product including computer-readable instructions. When the computer-readable instructions are executed on an electronic device, the electronic device implements the text classification method based on collaborative learning of large and small models of the aforementioned embodiment of the present application, or implements the model training method based on collaborative learning of large and small models of the aforementioned embodiment of the present application.

[0160] A computer-readable storage medium is also provided in an embodiment of the present application. The storage medium carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement the text classification method based on collaborative learning of large and small models in the aforementioned embodiment of the present application, or implement the model training method based on collaborative learning of large and small models in the aforementioned embodiment of the present application.

[0161] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0162] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0163] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0164] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk (SSD)), etc.

[0165] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.

Claims

1. A model training method based on collaborative learning of large and small models, characterized in that: include: Obtaining sample data of the current round, wherein the sample data can be used as training data for a text classification model, wherein the text classification model is a model with a smaller parameter scale than a large model; Calling the configured big model to instruct the big model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and obtain the training data generated by the big model in the current round; Optimizing and training the text classification model using the training data generated in the current round to obtain the text classification model after the current round of training, and evaluating whether the effect of the text classification model after the current round of training meets the set requirements; If not, for each piece of training data generated in the current round, determine the contribution of each piece of training data to the optimization training process of the text classification model; Determine the maximum similarity between each training data and the historical training data obtained before the current round; refer to the contribution and the maximum similarity of each training data to obtain the quality score of each training data, wherein the contribution is positively correlated with the quality score, and the maximum similarity is negatively correlated with the quality score; select the training data that meets the set high quality requirements as the sample data for the next round, return to execute the process of calling the large model to generate the next round of training data, and use the next round of training data to optimize the text classification model until the effect of the text classification model after the current round of training meets the set requirements, and obtain the final text classification model.

2. The method according to claim 1, characterized in that The process of calling the configured big model to instruct the big model to refer to the sample data of the current round to generate training data that can be used to train the text classification model includes: Obtain a prompt instruction prompt format template, wherein the prompt format template includes a task instruction and a sample data slot, wherein the task instruction is used to instruct the large model to generate training data for training a text classification model according to the sample data in the sample data slot; Fill the sample data of the current round into the sample data slot to obtain a first prompt instruction prompt, input the first prompt instruction prompt into the large model, and obtain the training data generated by the current round of the large model.

3. The method according to claim 1, characterized in that The process of evaluating whether the effect of the text classification model after the current round of training meets the set requirements includes: Use the configured test set to evaluate the text classification model after the current round of training to obtain the evaluation indicators of the current round; Determine whether the effect of the text classification model after the current round of training meets the set requirements based on whether the evaluation indicators of the current round reach the set indicator threshold; or, Compare the evaluation indicators of the current round with those of the previous round, and determine whether the effect of the text classification model after the current round of training meets the set requirements based on the comparison results.

4. The method according to claim 1, characterized in that: The process of obtaining the sample data of the current round includes: If the current round is the first round, several training data are randomly selected from the configured training set as sample data for the current round.

5. The method according to any one of claims 1 to 4, characterized in that: Before obtaining the sample data of the current round, it also includes: Performing initial training on the initial text classification model using the configured training set to obtain the text classification model after initial training; The configured test set is applied to perform an evaluation test on the text classification model after the initial training, and when it is determined that the effect of the text classification model after the initial training does not meet the set requirements, the step of obtaining the sample data of the current round is performed.

6. A text classification method based on collaborative learning of large and small models, characterized in that: include: Get the text to be classified; Sending the text to be classified into a text classification model to obtain a classification result output by the model; Among them, the text classification model is a model trained by the model training method based on collaborative learning of large and small models described in any one of claims 1 to 5.

7. A model training device based on collaborative learning of large and small models, characterized in that: include: A data acquisition unit, used to acquire sample data of the current round, wherein the sample data can be used as training data for a text classification model, wherein the text classification model is a model with a smaller parameter scale than a large model; A training data generating unit, used to call the configured large model to instruct the large model to refer to the sample data of the current round to generate training data that can be used to train the text classification model, and obtain the training data generated by the large model in the current round; A model optimization training and evaluation unit, used to optimize the text classification model using the training data generated in the current round, obtain the text classification model after the current round of training, and evaluate whether the effect of the text classification model after the current round of training meets the set requirements; A data scoring unit is used to determine the contribution of each piece of training data generated in the current round to the optimization training process of the text classification model when the effect of the text classification model after the current round of training does not meet the set requirements; Determine the maximum similarity between each training data and the historical training data obtained before the current round; refer to the contribution and the maximum similarity of each training data to obtain the quality score of each training data, wherein the contribution is positively correlated with the quality score, and the maximum similarity is negatively correlated with the quality score; select the training data that meets the set high quality requirements as the sample data for the next round, return to the execution training data generation unit, until the effect of the text classification model after the current round of training meets the set requirements, and obtain the final text classification model.

8. A text classification device based on collaborative learning of large and small models, characterized in that: include: A text acquisition unit, used for acquiring text to be classified; An output unit is used to input the text to be classified into a text classification model to obtain a classification result output by the model; wherein the text classification model is a model trained by the model training method based on collaborative learning of large and small models as described in any one of claims 1 to 5.

9. An electronic device, characterized in that: include: Memory and processor; The memory is used to store programs; The processor is used to execute the program to implement the various steps in the model training method based on collaborative learning of large and small models as described in any one of claims 1 to 5, or to implement the text classification method based on collaborative learning of large and small models as described in claim 6.

10. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the various steps in the model training method based on collaborative learning of large and small models as described in any one of claims 1 to 5, or implements the text classification method based on collaborative learning of large and small models as described in claim 6.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the various steps in the model training method based on collaborative learning of large and small models as described in any one of claims 1 to 5, or implements the text classification method based on collaborative learning of large and small models as described in claim 6.

Citation Information

Patent Citations

  • Data contribution excitation method and device supporting machine learning model training

    CN114897178A

  • Small model training method, device and system based on large model and storage medium

    CN117236409A

  • Text retouching training data screening method and device, related equipment and computer program product

    CN118246412A